limsMethod.detailPage = {

    init : function(param) {
        this.param = param;
        this.createPage();
    },

    createPage : function() {
        var _this = this;
        Gikam.create('layout', {
            id : 'sop-method-detail-layout',
            west : {
                width : '50%',
                title: 'T_LIMS_METHOD_VERSION.SERVICE_NAME',
                //_this.getBtnToolbar(),
                items : [ _this.getVersionsTabParam() ]
            },
            center : {
                title : 'GIKAM.FILE.ATTACHMENT',
                items : [ _this.getUploader()]
            },
            renderTo : Gikam.getLastModal().window.$dom,
        });
        return _this;
    },

    getBtnToolbar : function() {
        var _this = this;
        return {
            type : 'btnToolbar',
            items : [ {
                id : 'method-version-detail-back-button',
                type : 'button',
                text : 'GIKAM.BUTTON.BACK',
                icon : 'back',
                onClick : function() {
                    workspace.window.goBack();
                }
            } ]
        }
    },
    
    /*getBaseInfoTabParam : function() {
        var _this = this;

        return {
            type : 'tab',
            id : 'sop-method-detail-grid-tab',
            width : Gikam.width.N,
            fill : true,
            panels : [ {
                title : 'MODULE.COREDATA.limsMethod.TAB.INFO_GRID',
                items : [ {
                    type : 'grid',
                    id : 'sop-method-detail-grid',
                    url : _this.getCompUrl('baseInfoForm'),
                    columns : limsMethod.getAuditDetailListColumns(),
                    service : 'methodServiceImpl'
                } ]
            }]
       }
    },*/
    
    getVersionsTabParam : function() {
        var _this = this;
        return {
            type : 'grid',
            id : 'method-version-detail-grid',
            url : limsMethod.versionUrl + '/queries/raw',
            requestData: {
                methodCode_EQ: _this.param.id
            },
            //url : _this.getCompUrl('methodVersionListGrid'),
            columns : limsMethod.getVersionListColumns(),
            onRowActive : function(index, row) {
                _this.loadListInfo(row);
            },
            onLoadSuccess : function(rows) {
                if (!Gikam.isEmpty(rows)) {
                    this.activeRowByIndex(0);
                } else {
                    _this.loadListInfo();
                }
            },
            readonly : true,
            service : 'methodVersionServiceImpl'
        }
    },

    loadListInfo : function(row) {
        Gikam.getAsyncComp('method-version-detail-detail-uploader').done(function (grid) {
            if (row) {
                grid.setOptions({
                    bizId : row.id
                });
            } else {
                grid.setOptions({
                    bizId : -1
                });
                grid.cleanData();
            }
        })
    },

    getUploader : function() {
        var _this = this;
        return {
            type : 'uploader',
            id : 'method-version-detail-detail-uploader',
            filter : false,
            dbTable : 'T_LIMS_METHOD_VERSION',
            readonly : true,
        }
    },
    
    /*getCompUrl : function(name) {
        if (Gikam.isEmpty(this.param.id)) {
            return '';
        }
        return Gikam.printf(this.urlManager[name], {
            id : this.param.id
        });
    },*/
    
    /*urlManager : {
        baseInfoForm : limsMethod.baseUrl + '/baseInfo/{id}',
        methodVersionListGrid : limsMethod.versionUrl + '/{id}',
    }*/
    
}
